import random

class TwoDualFifoModel():

  def __init__(self):
    pass

  def SetSeed(self,seed):
    self.seed = seed
    random.seed(seed)

  def Run(self):
    fifo_wr_en_ratio = random.randint(2,8)
    fifo_rd_en_ratio = random.randint(2,8)
    fifo_data_width  = random.randint(1,63)
    fifo_addr_width  = random.randint(1,16)
    fifo_data_depth  = random.randint(2**(fifo_addr_width-1)+1,2**(fifo_addr_width))

    # multiples of two
    fifo_data_depth  = int(fifo_data_depth / 2) * 2;

    with open("top.svh","w") as f:
      f.write("`define FIFO_WR_EN_RATIO %d\n" % fifo_wr_en_ratio)
      f.write("`define FIFO_RD_EN_RATIO %d\n" % fifo_rd_en_ratio)
      f.write("`define DATA_WIDTH       %d\n" % fifo_data_width )
      f.write("`define ADDR_WIDTH       %d\n" % fifo_addr_width )
      f.write("`define DATA_DEPTH       %d\n" % fifo_data_depth )

    fifo_data_list = [ random.randint(0,(2**fifo_data_width)-1) for _ in range(fifo_data_depth*5)]

    with open('fifo_data.hex', 'w') as f:
      for d in fifo_data_list:
        f.write('%x\n' % d)
